class Comentario < ActiveRecord::Base
  validates_length_of :conteudo, :maximum => 400, :message => "Máximo de 400 caracteres no campo conteúdo."
  validates_presence_of :nome,:email,:conteudo, :message => "é um campo obrigatório."
  validates_format_of :email,
  	                      :with => /\A[\w\._%-]+@[\w\.-]+\.[a-zA-Z]{2,4}\z/,
  	                      :message => "com formato incorreto."

  validates_uniqueness_of :conteudo, :scope => [:nome, :email], :on => :create, :message => "comentário já postado"
  validates_format_of :conteudo, :without => /^([a-z | A-Z | 0-9]+)*(http|https|www)(:\/\/|.)[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$?([a-z | A-Z | 0-9 | ]+)*/ix , :message => "sem URL" 
  belongs_to :evento
  
  

end
